package com.ryan.day02.demo02;

import java.util.ArrayList;
import java.util.Random;

public class DemoArrayListReturn {
    public static void main(String[] args) {
        Random random = new Random();
        ArrayList<Integer> arrayBig = new ArrayList<>();
        ArrayList<Integer> arrayLittle = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            int i1 = random.nextInt(100) + 1;
            arrayBig.add(i1);
        }
        System.out.println(arrayBig);
/*        for (int i = 0; i < arrayBig.size(); i++) {
            if(arrayBig.get(i)%2 == 0){
                arrayLittle.add(arrayBig.get(i));
            }
        }
        System.out.println(arrayLittle);*/
        ArrayList<Integer> smallArray = getSmallArray(arrayBig);
        System.out.println(smallArray.size());
        System.out.println(smallArray);
    }

    public static ArrayList<Integer> getSmallArray(ArrayList<Integer> bigArrayList){
        ArrayList<Integer> samllArrayList = new ArrayList<>();
        for (int i = 0; i < bigArrayList.size(); i++) {
            Integer integer = bigArrayList.get(i);
            if (integer%2 == 0){
                samllArrayList.add(integer);
            }
        }
        return samllArrayList;
    }
}
